package com.lagou.edu.dao;
import com.lagou.edu.pojo.LagouAuthCode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

/**
 * @author Administrator
 */
public interface LagouAuthCodeDao extends JpaRepository<LagouAuthCode,Integer> {

    /**
     * 查询有效期最长的数据
     *
     * @param email
     * @param name
     * @return
     */
    @Query(value = "select u.* from lagou_auth_code u where u.email = ?1 and u.code=?2 order by u.expiretime desc limit 1 ",nativeQuery=true)
    LagouAuthCode getByEmailAndCodeByExpiretimeDesc(String email, String name);
}